package com.ruoyi.withdrawal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.withdrawal.domain.WithdrawalApplication;
import com.ruoyi.withdrawal.service.IWithdrawalApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现申请Controller
 * 
 * @author ruoyi
 * @date 2025-11-20
 */
@RestController
@RequestMapping("/withdrawal/withdrawal")
public class WithdrawalApplicationController extends BaseController
{
    @Autowired
    private IWithdrawalApplicationService withdrawalApplicationService;

    /**
     * 查询提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:list')")
    @GetMapping("/list")
    public TableDataInfo list(WithdrawalApplication withdrawalApplication)
    {
        startPage();
        List<WithdrawalApplication> list = withdrawalApplicationService.selectWithdrawalApplicationList(withdrawalApplication);
        return getDataTable(list);
    }

    /**
     * 导出提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:export')")
    @Log(title = "提现申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WithdrawalApplication withdrawalApplication)
    {
        List<WithdrawalApplication> list = withdrawalApplicationService.selectWithdrawalApplicationList(withdrawalApplication);
        ExcelUtil<WithdrawalApplication> util = new ExcelUtil<WithdrawalApplication>(WithdrawalApplication.class);
        util.exportExcel(response, list, "提现申请数据");
    }

    /**
     * 获取提现申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(withdrawalApplicationService.selectWithdrawalApplicationById(id));
    }

    /**
     * 新增提现申请
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:add')")
    @Log(title = "提现申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WithdrawalApplication withdrawalApplication)
    {
        return toAjax(withdrawalApplicationService.insertWithdrawalApplication(withdrawalApplication));
    }

    /**
     * 修改提现申请
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:edit')")
    @Log(title = "提现申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WithdrawalApplication withdrawalApplication)
    {
        return toAjax(withdrawalApplicationService.updateWithdrawalApplication(withdrawalApplication));
    }

    /**
     * 删除提现申请
     */
    @PreAuthorize("@ss.hasPermi('withdrawal:withdrawal:remove')")
    @Log(title = "提现申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(withdrawalApplicationService.deleteWithdrawalApplicationByIds(ids));
    }
}
